<template>
  <div class="introduceBox">
    <div class="imgBox">
      <div class="backImg"></div>
      <img :src="detailObj.al.picUrl" alt="" />
    </div>
    <div class="introduceBoxRight">
      <div class="introduceBoxTitle">
        <p class="label"></p>
        <div class="songSheetName" :title="detailObj.name">
          {{ detailObj.name }}
        </div>
      </div>
      <p class="singer">
        <span>歌手：</span>
        <span class="singerName" v-for="item in detailObj.ar" :key="item.id"
          >{{ item.name }}
        </span>
      </p>
      <p class="Album">
        <span>所属专辑：</span>
        <span class="AlbumName">{{ detailObj.al.name }}</span>
      </p>
      <div class="btnBox">
        <div class="playBtn">
          <i></i>
          <span>播放</span>
        </div>
        <div class="addSongSheet"></div>
        <div class="btnClass">
          <i>收藏</i>
        </div>
        <div class="btnClass forward">
          <i>分享</i>
        </div>
        <div class="btnClass download">
          <i>下载</i>
        </div>
        <div class="btnClass comment">
          <i>{{ commentTotal }}</i>
        </div>
      </div>

      <div v-if="lyric" :class="isOPen ? 'descriptionte' : 'description'">
        <pre class="lyricTxt">{{
          ((this.lyric && this.lyric.lrc && this.lyric.lrc.lyric) || "暂无歌词")
            | lyricTxt
        }}</pre>
        <p class="lyricUser" v-if="this.lyric.lyricUser">
          歌词贡献：<span>{{
            (this.lyric &&
              this.lyric.lyricUser &&
              this.lyric.lyricUser.nickname) ||
            ""
          }}</span>
        </p>
      </div>
      <span class="openBtn" v-if="!isOPen" @click="isOPen = true"
        >展开<i></i
      ></span>
      <span class="PutItAwayBtn" v-if="isOPen" @click="isOPen = false"
        >收起<i></i
      ></span>
    </div>
  </div>
</template>

<script>
import { musicDetail } from "@/api";
import { mapActions } from "vuex";
export default {
  props: {
    detailObj: {
      type: Object,
      default: {},
    },
    lyric: {
      type: Object,
      default: {},
    },
    commentTotal: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      isOPen: false,
    };
  },
  created() {},
  filters: {
    lyricTxt(str) {
      str = str.replace(/\[.*?\]/g, "");
      return str;
    },
  },
  methods: {
    ...mapActions("musicStore", ["songSheetPlay"]),
  },
};
</script>

<style lang="scss" scoped>
.introduceBox {
  width: 100%;
  display: flex;
  .imgBox {
    width: 200px;
    height: 200px;
    position: relative;
    padding: 2px;
    .backImg {
      height: 100%;
      width: 100%;
      position: absolute;
      left: 0;
      top: 0;
      background: url("./../../assets/imges/background.png") no-repeat -140px -580px;
      z-index: 10;
    }
    img {
      width: 130px;
      height: 130px;
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      margin: auto;
      z-index: 5;
    }
  }
  .introduceBoxRight {
    flex: 1;
    overflow: hidden;
    margin-left: 30px;
    .introduceBoxTitle {
      display: flex;
      .label {
        width: 54px;
        height: 24px;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat 0 -463px;
        margin-right: 10px;
      }
      .songSheetName {
        flex: 1;
        line-height: 24px;
        font-size: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
    .singer,
    .Album {
      color: #999;
      margin: 10px 0;
      .singerName,
      .AlbumName {
        color: #0c73c2;
        cursor: pointer;
      }
    }
    .btnBox {
      .playBtn {
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat 0 -387px;
        padding: 0 5px 0 0;
        height: 31px;
        display: inline-block;
        color: #fff;
        vertical-align: middle;
        cursor: pointer;
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1622px;
          width: 20px;
          height: 18px;
          margin: 6px 2px 2px 5px;
          display: inline-block;
          vertical-align: middle;
        }
        span {
          vertical-align: middle;
        }
      }
      .addSongSheet {
        margin-right: 5px;
        line-height: 30px;
        width: 31px;
        display: inline-block;
        height: 31px;
        vertical-align: middle;
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat 0 -1588px;
      }
      .btnClass {
        color: #333;
        background: url("./../../assets/imges/backgroundStripe.png") no-repeat
          right -1020px;
        padding: 0 5px 0 0;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
        margin-right: 5px;
        i {
          padding-right: 2px;
          padding-left: 28px;
          height: 31px;
          line-height: 30px;
          display: inline-block;
          min-width: 23px;
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -977px;
          cursor: pointer;
        }
      }
      .forward {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1225px;
        }
      }
      .download {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -2761px;
        }
      }
      .comment {
        i {
          background: url("./../../assets/imges/backgroundStripe.png") no-repeat
            0 -1465px;
        }
      }
    }
    .description {
      color: #666;
      line-height: 18px;
      display: -webkit-box;
      overflow: hidden;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 20;
    }
    .descriptionte {
      color: #666;
      line-height: 18px;
    }
    .lyricTxt {
      line-height: 23px;
      color: #333;
      font-size: 12px;
      margin-top: 20px;
    }
    .lyricUser {
      color: #666;
      text-align: right;
      span {
        color: #0c73c2;
        cursor: pointer;
      }
    }
    .openBtn {
      color: #0c73c2;
      float: right;
      i {
        width: 11px;
        margin-left: 3px;
        height: 8px;
        display: inline-block;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat -65px -520px;
      }
    }
    .PutItAwayBtn {
      color: #0c73c2;
      float: right;
      i {
        width: 11px;
        margin-left: 3px;
        height: 8px;
        display: inline-block;
        background: url("./../../assets/imges/btnIconTwo.png") no-repeat -45px -520px;
      }
    }
  }
}
</style>